package android.meetingatsb.widget

import android.app.Fragment
import android.meetingatsb.R
import android.meetingatsb.common.FontAwesome
import android.meetingatsb.common.Requirement
import android.os.Bundle
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView

class RequirementFragment : Fragment() {
    lateinit var group: TextView
    lateinit var location: TextView
    lateinit var time: TextView
    lateinit var addition: TextView
    override fun onCreateView(inflater: LayoutInflater?, container: ViewGroup?, savedInstanceState: Bundle?): View {
        val view = inflater!!.inflate(R.layout.fragment_requirement_info, container, false)
        bindWidgets(view)
        setData(view)
        return view
    }

    private fun bindWidgets(view: View) {
        group = view.findViewById(R.id.group)
        location = view.findViewById(R.id.location)
        time = view.findViewById(R.id.time)
        addition = view.findViewById(R.id.addition)
    }

    private fun setData(view: View) {
        //设置图标字体
        val font = FontAwesome.getFont(activity)
        (view.findViewById<TextView>(R.id.group_icon)).typeface = font
        (view.findViewById<TextView>(R.id.location_icon)).typeface = font
        (view.findViewById<TextView>(R.id.time_icon)).typeface = font
        (view.findViewById<TextView>(R.id.addition_icon)).typeface = font

        val requirement = arguments.get("requirement") as Requirement

        group.text = requirement.group
        Log.i("123",requirement.location)
        location.text = requirement.location
        time.text = requirement.time
        addition.text = requirement.addition
    }

}